import numpy as np
import cv2 as cv
import sys

help_str = """
w: blockSize += 2
s: blockSize -= 2

q: exit
"""

if __name__ == "__main__":
    file = "../../res/121.jpg"
    if len(sys.argv) > 1:
        file = sys.argv[1]
    # 1.显示原图
    img = cv.resize(cv.imread(file), None, fx=0.5, fy=0.5)
    cv.imshow("img", img)

    # 2.手动调节参数
    rang = 5
    while True:
        # 应用均值滤波
        blur_img = cv.GaussianBlur(img, (rang, rang), 0)
        cv.imshow("blur_img", blur_img)
        key = cv.waitKey(0)
        if key == ord("q"):
            break
        elif key == ord("w"):
            rang += 2
            rang = min(99, rang)
        elif key == ord("s"):
            rang -= 2
            rang = max(1, rang)
        print(f"rang:{rang}")

    cv.destroyAllWindows()
